import {Entity, PrimaryGeneratedColumn, Column, ManyToMany, Index} from "typeorm";
import {BookEntity} from "~/modules/books/book.entity";
import {CommonEntity} from "~/common/entity/common.entity";

@Index(["id"])
@Entity({name: "books_author"})
export class AuthorEntity extends CommonEntity {

  @Column({type: "varchar", length: 10, comment: "作者姓名"})
  name: string;

  @Column({type: "varchar", length: 10, comment: "朝代", nullable: true})
  dynasty: string;

  @ManyToMany(() => BookEntity, book => book.authors)
  books: BookEntity[];
}
